﻿package mortal.game.view.mainUI.smallMap
{
    import Message.Public.*;
    import com.fyGame.fyMap.*;
    import com.gengine.core.frame.*;
    import com.gengine.debug.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.event.*;
    import mortal.common.net.*;
    import mortal.component.gconst.*;
    import mortal.game.*;
    import mortal.game.control.subControl.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.ai.ais.*;
    import mortal.game.scene3D.events.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.scene3D.map3D.AstarAnyDirection.*;
    import mortal.game.scene3D.map3D.sceneInfo.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.utils.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.mainUI.smallMap.scene.*;
    import mortal.game.view.mainUI.smallMap.view.data.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class SmallMapController extends Controller
    {
        private var _module:SmallMapModule;
        private var _mapIdLoader:MapLoader;
        private var _scenePath:ScenePathShower;
        private var _toBeClickTypeData:SmallMapTypeIconData;
        private var _lastTimerId:int;
        private var _timer:SecTimer;
        private var _isCurMap:Boolean = true;
        private var _flyTarget:SPassTo;

        public function SmallMapController()
        {
            return;
        }// end function

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.SmallMapChangeTab, this.tabChangeHandler);
            Dispatcher.addEventListener(EventName.SMallMapImgLoaded, this.mapLoadedHandler);
            Dispatcher.addEventListener(EventName.StageResize, this.stageResizeHandler);
            Dispatcher.addEventListener(EventName.SmallMapShowHide, this.smallMapShowHideHandler);
            Dispatcher.addEventListener(EventName.SmallMapClick, this.smallMapClickHandler);
            Dispatcher.addEventListener(EventName.SmallMapTypeIconClick, this.typeIconClickedHandler);
            Dispatcher.addEventListener(EventName.SmallMapTypeIconDoubleClick, this.typeIconDoubleClickedHandler);
            Dispatcher.addEventListener(EventName.SmallMapDoubleClick, this.smallMapDoubleClickHandler);
            Dispatcher.addEventListener(EventName.SmallMapFlybootReq, this.smallMapFlybootReqHandler);
            Dispatcher.addEventListener(EventName.SmallMapShowCurPoint, this.showCurPointHandler);
            Dispatcher.addEventListener(EventName.SmallMapShowTypeChange, this.showTypeChangeHandler);
            Dispatcher.addEventListener(EventName.SmallMapShowCustomMapPoinWin, this.showCustomMapPointWinHandler);
            Dispatcher.addEventListener(EventName.SmallMapSaveCustomPoint, this.saveCustomPointHandler);
            Dispatcher.addEventListener(EventName.FlyBoot, this.flyReqHandler);
            Dispatcher.addEventListener(EventName.AI_FlyBootCalled, this.flyBootCalledHandler);
            NetDispatcher.addCmdListener(ServerCommand.SmallMapCustomMapPointGot, this.customMapPointGotHandler);
            NetDispatcher.addCmdListener(ServerCommand.MapPointUpdate, this.mapPointUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.AI_FlyBootFail, this.flyBootFailHandler);
            Dispatcher.addEventListener(EventName.RoleStartMoveByPath, this.moveStartHandler);
            FrEventDispatcher.instance.proxyAddEventListener(RolePlayer.instance, PlayerEvent.GIRD_WALK_END, this.roleWalkGridEndHandler, false, 0, true);
            FrEventDispatcher.instance.proxyAddEventListener(RolePlayer.instance, PlayerEvent.JumpPointStart, this.startJumpHandler, false, 0, true);
            Dispatcher.addEventListener(EventName.AI_Canceled, this.aiCanceledHandler);
            Dispatcher.addEventListener(EventName.AI_AllFinished, this.allAIFinishedHandler);
            Dispatcher.addEventListener(EventName.Scene_Update, this.sceneUpdateHandler);
            Dispatcher.addEventListener(EventName.SmallMapClickWorldRegion, this.clickWorldRegionHandler);
            Dispatcher.addEventListener(EventName.PetBreakCopySceneEntityPetUpdate, this.onPetBreakCopySceneEntityPetUpdate);
            Dispatcher.addEventListener(EventName.SmallMapPathChanged, this.pathChangedHandler);
            NetDispatcher.addCmdListener(ServerCommand.GroupPlayerPosMove, this.teamatePlaceChangedHandler);
            NetDispatcher.addCmdListener(ServerCommand.GroupPlayerInfoChange, this.teamatePlaceChangedHandler);
            Dispatcher.addEventListener(EventName.SceneRemoveGroupmate, this.teamatePlaceChangedHandler);
            Dispatcher.addEventListener(EventName.SmallMapBossKilledUpdate, this.updateBossKillded);
            return;
        }// end function

        private function updateBossKillded(param1 = null) : void
        {
            if (this._module == null || this._module.isHide || this._module.typeShower == null)
            {
                return;
            }
            var _loc_2:* = cache.smallmap.getDataByType(SmallMapShowType.MapShowTypeBoss, Game.mapInfo.mapId);
            this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowTypeBoss, this._module.mapScale, _loc_2);
            return;
        }// end function

        private function teamatePlaceChangedHandler(param1:Object) : void
        {
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            var _loc_2:* = this._module.mapScale;
            var _loc_3:* = !ClientSetting.local.getIsDone(IsDoneType.MapShowTypeTeamate);
            if (!cache.group.isInGroup || !_loc_3)
            {
                this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowType_Teamate, _loc_2, []);
            }
            else
            {
                this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowType_Teamate, _loc_2, cache.smallmap.getTeamates());
            }
            return;
        }// end function

        private function typeIconClickedHandler(event:DataEvent) : void
        {
            if (!BuffUtil.isCanRoleWalk())
            {
                MsgManager.showRollTipsMsg(Language.getString(21320));
                return;
            }
            var _loc_2:* = event.data as SmallMapTypeIconData;
            if (_loc_2 == null || Game.sceneInfo == null)
            {
                return;
            }
            var _loc_3:int = 0;
            if (SmallMapModule._mapInfo != null)
            {
                _loc_3 = SmallMapModule._mapInfo.mapId;
            }
            else
            {
                _loc_3 = MapFileUtil.mapID;
            }
            if (_loc_2.type >= 1 && _loc_2.type <= 7)
            {
                AIManager.cancelAll();
                if (AIManager.addMoveToOtherMap(Game.sceneInfo.sMapDefine.mapId, _loc_3, new Point(_loc_2.x, _loc_2.y), 0, this.afterMoveToMap, [_loc_2]))
                {
                    this.startAI();
                }
            }
            return;
        }// end function

        private function startAI() : void
        {
            if (!AIManager.isWorking)
            {
                AIManager.start();
            }
            return;
        }// end function

        private function afterMoveToMap(param1:SmallMapTypeIconData) : void
        {
            var _loc_2:SPassPoint = null;
            if (param1.type == SmallMapShowType.MapShowTypePassPoint)
            {
                _loc_2 = param1.value as SPassPoint;
                Log.error("意外找出口：6");
                AIManager.addPassToMap(_loc_2);
                this.startAI();
            }
            else if (param1.type == SmallMapShowType.MapShowTypeBoss)
            {
                AIManager.addAutoFight();
                this.startAI();
            }
            else if (param1.type >= SmallMapShowType.MapShowTypeTaskNpc && param1.type <= SmallMapShowType.MapShowTypeTaskMining)
            {
                AIManager.addClickNpcAI(int(param1.value));
                this.startAI();
            }
            else
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.SmallMapClick, {x:param1.x, y:param1.y}));
            }
            return;
        }// end function

        private function typeIconDoubleClickedHandler(event:DataEvent) : void
        {
            if (!BuffUtil.isCanRoleWalk())
            {
                MsgManager.showRollTipsMsg(Language.getString(21320));
                return;
            }
            if (!FlyBootAI.checkCanFly())
            {
                return;
            }
            var _loc_2:* = event.data as SmallMapTypeIconData;
            this._toBeClickTypeData = _loc_2;
            GameController.guide.checkAndBuyFlyBoot(this.startDoubleClickIcon);
            return;
        }// end function

        private function startDoubleClickIcon() : void
        {
            if (this._toBeClickTypeData == null)
            {
                return;
            }
            if (this._toBeClickTypeData == null || Game.sceneInfo == null)
            {
                return;
            }
            var _loc_1:int = 0;
            if (SmallMapModule._mapInfo != null)
            {
                _loc_1 = SmallMapModule._mapInfo.mapId;
            }
            var _loc_2:* = new SPassTo();
            _loc_2.mapId = _loc_1;
            _loc_2.toPoint = new SPoint();
            _loc_2.toPoint.x = this._toBeClickTypeData.x;
            _loc_2.toPoint.y = this._toBeClickTypeData.y;
            if (!AIManager.addFlyBoot(_loc_2))
            {
            }
            switch(this._toBeClickTypeData.type)
            {
                case SmallMapShowType.MapShowTypePassPoint:
                {
                    break;
                }
                case SmallMapShowType.MapShowTypeBoss:
                {
                    break;
                }
                case SmallMapShowType.MapShowTypeTaskNpc:
                case SmallMapShowType.MapShowTypeTaskEScort:
                case SmallMapShowType.MapShowTypeTaskLueMo:
                case SmallMapShowType.MapShowTypeTaskMining:
                case SmallMapShowType.MapShowTypeTaskLoop:
                case SmallMapShowType.MapShowTypeChangeCareer:
                {
                    if (this._lastTimerId > 0)
                    {
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._toBeClickTypeData = null;
            return;
        }// end function

        private function preClickNpc(param1:SmallMapTypeIconData) : void
        {
            this.addShowNpc([param1, 70]);
            return;
        }// end function

        private function addShowNpc(param1:Array) : void
        {
            var _loc_2:* = param1[0];
            var _loc_3:* = param1[1];
            if (_loc_3 == 0)
            {
                return;
            }
            param1[1] = _loc_3 - 1;
            var _loc_4:* = ThingUtil.npcUtil.getNpc(int(_loc_2.value));
            if (_loc_4 == null)
            {
                if (_loc_3 > 0)
                {
                    this._lastTimerId = setTimeout(this.addShowNpc, 60, param1);
                }
                return;
            }
            this._lastTimerId = -1;
            AIManager.addClickNpcAI(_loc_2.value);
            this.startAI();
            return;
        }// end function

        private function pathChangedHandler(event:DataEvent) : void
        {
            this.updateMapPathShows();
            return;
        }// end function

        private function onPetBreakCopySceneEntityPetUpdate(event:DataEvent) : void
        {
            if (event.data)
            {
                FrEventDispatcher.instance.proxyAddEventListener(ThingUtil.entityUtil.getSelfPetEntity(), PlayerEvent.GIRD_WALK_END, this.roleWalkGridEndHandler, false, 0, true);
                this.roleWalkGridEndHandler(null);
            }
            else
            {
                FrEventDispatcher.instance.proxyRemoveEventListener(ThingUtil.entityUtil.getSelfPetEntity(), PlayerEvent.GIRD_WALK_END, this.roleWalkGridEndHandler);
            }
            return;
        }// end function

        private function allAIFinishedHandler(event:DataEvent) : void
        {
            this.moveEndHandler(null);
            return;
        }// end function

        private function aiCanceledHandler(event:DataEvent) : void
        {
            this.moveEndHandler(null);
            return;
        }// end function

        private function allEntityPointsHandler(param1:Object = null) : void
        {
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            var _loc_2:* = cache.smallmap.getAllChangabelDatas();
            if (_loc_2 == null || _loc_2.length == 0)
            {
                this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowType_Changable, this._module.mapScale, []);
                return;
            }
            var _loc_3:* = _loc_2[0] as SmallMapTypeIconData;
            this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowType_Changable, this._module.mapScale, _loc_2);
            return;
        }// end function

        private function clickWorldRegionHandler(event:DataEvent) : void
        {
            var _loc_3:Array = null;
            var _loc_2:* = event.data as SmallMapWorldRegionData;
            if (_loc_2.mapId <= 0)
            {
                _loc_3 = cache.smallmap[_loc_2.url];
                this._module.changeToRegion(_loc_3);
            }
            else if (_loc_2.mapId > 0)
            {
                MapLoader.instance.loadMapData(_loc_2.mapId, this.onMapIdLoadedHandler);
            }
            return;
        }// end function

        private function onMapIdLoadedHandler(param1:FyMapInfo) : void
        {
            if (this._module && !this._module.isHide && !this._module.isShowingAutoFightMap())
            {
                this._module.changeToCur();
                this._module.updateToMap(param1);
            }
            return;
        }// end function

        private function clearForceIcons() : void
        {
            cache.smallmap.allEntityPoints = null;
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            this._module.typeShower.updateTypeShow(SmallMapShowType.MapShowType_Changable, this._module.mapScale, []);
            return;
        }// end function

        private function sceneUpdateHandler(event:DataEvent) : void
        {
            this.teamatePlaceChangedHandler(null);
            this.clearForceIcons();
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            this._module.changeToCur();
            this._module.updateToMap(Game.mapInfo);
            this.moveEndHandler(null);
            if (GameMapUtil.curMapState.isForceTypeShowMap())
            {
                this.startUpdateForceTimer();
            }
            else
            {
                this.stopUpdateForceTimer();
            }
            return;
        }// end function

        private function showCustomMapPointWinHandler(event:DataEvent) : void
        {
            if (this._module && !this._module.isHide && cache.smallmap.customMapPointArr != null)
            {
                this._module.showHideCustomXYWin(cache.smallmap.customMapPointArr);
            }
            return;
        }// end function

        private function saveCustomPointHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SCustomPoint;
            if (_loc_2 == null)
            {
                return;
            }
            cache.smallmap.addCustomMapPoint(_loc_2);
            GameProxy.sceneProxy.saveCustomMapPoint(_loc_2.index, _loc_2.name, _loc_2.mapId, _loc_2.point);
            if (this._module != null && !this._module.isHide)
            {
                this._module.rightDown.updateDatas(cache.smallmap.customMapPointData);
            }
            return;
        }// end function

        private function flyReqHandler(event:DataEvent) : void
        {
            if (!FlyBootAI.checkCanFly())
            {
                return;
            }
            var _loc_2:* = event.data as SPassTo;
            this._flyTarget = _loc_2;
            GameController.guide.checkAndBuyFlyBoot(this.startFly);
            return;
        }// end function

        private function customMapPointGotHandler(param1:Object) : void
        {
            if (this._module != null && !this._module.isHide)
            {
                this._module.rightDown.updateDatas(cache.smallmap.customMapPointData);
            }
            return;
        }// end function

        private function mapPointUpdateHandler(param1:SPassTo) : void
        {
            CallLater.addCallBack(this.nextFrameMapPointUpdate);
            return;
        }// end function

        private function nextFrameMapPointUpdate() : void
        {
            if (this._module && !this._module.isHide)
            {
                this._module.clearPaths();
                this._module.updateSelfXY();
            }
            return;
        }// end function

        private function flyBootFailHandler(param1:SPassTo) : void
        {
            var _loc_2:* = new Point(param1.toPoint.x, param1.toPoint.y);
            AIManager.cancelAll();
            AIManager.addMoveToOtherMap(Game.mapInfo.mapId, param1.mapId, new Point(param1.toPoint.x, param1.toPoint.y));
            AIManager.start();
            return;
        }// end function

        private function flyBootCalledHandler(event:DataEvent) : void
        {
            if (this._module && !this._module.isHide)
            {
                this._module.clearPaths();
                this._module.typeShower.showFlyBoot(this._module.curMapId, false);
                this._module.typeShower.showTargetPoint(false);
            }
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._module == null)
            {
                this._module = new SmallMapModule();
                this._module.addEventListener(Event.ADDED_TO_STAGE, this.moduleAddToStageHandler);
            }
            return this._module;
        }// end function

        private function moduleAddToStageHandler(event:Event) : void
        {
            if (!GameMapUtil.curMapState.isForceTypeShowMap())
            {
                return;
            }
            this.startUpdateForceTimer();
            this._module.addEventListener(Event.REMOVED_FROM_STAGE, this.moduleRemoveHandler);
            return;
        }// end function

        private function moduleRemoveHandler(event:Event) : void
        {
            this.stopUpdateForceTimer();
            this._module.removeEventListener(Event.REMOVED_FROM_STAGE, this.moduleRemoveHandler);
            return;
        }// end function

        private function startUpdateForceTimer() : void
        {
            if (this._timer == null)
            {
                this._timer = new SecTimer(1);
                this._timer.addListener(TimerType.ENTERFRAME, this.onEverySecondUpdateForce);
            }
            if (!this._timer.running)
            {
                this._timer.start();
            }
            return;
        }// end function

        private function onEverySecondUpdateForce(param1 = null) : void
        {
            this.allEntityPointsHandler();
            return;
        }// end function

        private function stopUpdateForceTimer() : void
        {
            if (this._timer != null && this._timer.running)
            {
                this._timer.stop();
            }
            return;
        }// end function

        private function tabChangeHandler(event:DataEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_2:* = int(event.data);
            switch(_loc_2)
            {
                case 0:
                {
                    this._module.changeToRegion(cache.smallmap.getRegionDataByMapId(Game.mapInfo.mapId));
                    this._module.title = Language.getString(21323);
                    break;
                }
                case 1:
                {
                    this._module.changeToCur();
                    this._module.updateToMap(Game.mapInfo);
                    this._module.title = Language.getString(21324);
                    break;
                }
                case 2:
                {
                    _loc_3 = this.getAutofightMapId(true, 0);
                    this._module.changeToAutoFight();
                    MapLoader.instance.loadMapData(_loc_3, this.autoFightMapIdLoadedHandler);
                    this._module.title = Language.getString(21325);
                    break;
                }
                case 3:
                {
                    _loc_3 = this.getAutofightMapId(true, 1);
                    this._module.changeToAutoFight();
                    MapLoader.instance.loadMapData(_loc_3, this.autoFightMapIdLoadedHandler);
                    this._module.title = Language.getString(21326);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function getAutofightMapId(param1:Boolean = true, param2:int = -1, param3:Boolean = false) : int
        {
            var _loc_5:int = 0;
            var _loc_4:* = cache.role.roleInfo.level;
            if (param1)
            {
                _loc_5 = 90012;
                if (_loc_4 <= 54)
                {
                    if (param3)
                    {
                        _loc_5 = 90000;
                    }
                    else
                    {
                        _loc_5 = this.randomOneLowLvMap(param2);
                    }
                }
                else if (_loc_4 <= 69)
                {
                    _loc_5 = 90001;
                }
                else if (_loc_4 <= 79)
                {
                    _loc_5 = 90010;
                }
            }
            else
            {
                _loc_5 = 10006;
                if (_loc_4 <= 54)
                {
                    if (param3)
                    {
                        _loc_5 = 10004;
                    }
                    else
                    {
                        _loc_5 = this.randomOneLowLvMap(param2);
                    }
                }
                else if (_loc_4 <= 69)
                {
                    _loc_5 = 10005;
                }
            }
            return _loc_5;
        }// end function

        private function randomOneLowLvMap(param1:int) : int
        {
            var _loc_2:* = GameMapConfig.instance.getMapInfo(90011);
            if (_loc_2 == null)
            {
                return 90000;
            }
            if (param1 == 0)
            {
                return 90000;
            }
            if (param1 == 1)
            {
                return 90011;
            }
            return int(Math.random() < 0.5 ? (90000) : (90011));
        }// end function

        private function autoFightMapIdLoadedHandler(param1:FyMapInfo) : void
        {
            if (this._module && !this._module.isHide)
            {
                this._module.changeToAutoFight();
                this._module.updateToMap(param1);
            }
            return;
        }// end function

        private function mapLoadedHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as FyMapInfo;
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            this.updateSmallMapAll(_loc_2.mapId);
            return;
        }// end function

        private function updateSmallMapAll(param1:int) : void
        {
            var _loc_4:Object = null;
            this._isCurMap = param1 == Game.mapInfo.mapId;
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            this._module.rightTop.updateItems(cache.smallmap.getRightTopShowTypes());
            this.updateMapPathShows();
            if (!this._isCurMap)
            {
                this._module.typeShower.showTargetPoint(false);
                this._module.typeShower.showFlyBoot(this._module.curMapId, false);
            }
            var _loc_2:* = cache.smallmap.getRightTopShowTypes();
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_4 = _loc_2[_loc_3];
                this.updateMapPointTypeShow(_loc_4, param1);
                _loc_3++;
            }
            if (cache.smallmap.customMapPointArr == null)
            {
                GameProxy.sceneProxy.getCustomMapPoint();
            }
            else
            {
                this._module.rightDown.updateDatas(cache.smallmap.customMapPointData);
            }
            return;
        }// end function

        private function updateMapPointTypeShow(param1:Object, param2:int) : void
        {
            var _loc_6:int = 0;
            var _loc_7:Array = null;
            if (!this._module || this._module.isHide)
            {
                return;
            }
            var _loc_3:* = this._module.mapScale;
            var _loc_4:* = param1["type"];
            var _loc_5:* = !ClientSetting.local.getIsDone(_loc_4);
            if (_loc_4 == SmallMapShowType.MapShowTypeSelf)
            {
                this._module.pathShower.showHideSelfIcon(_loc_5);
                return;
            }
            if (_loc_4 == SmallMapShowType.MapShowTypeTaskNpc)
            {
                _loc_6 = SmallMapShowType.MapShowTypeTaskNpc;
                while (_loc_6 <= SmallMapShowType.MapShowTypeChangeCareer)
                {
                    
                    _loc_4 = _loc_6;
                    if (_loc_5)
                    {
                        _loc_7 = cache.smallmap.getDataByType(_loc_4, param2);
                        this._module.typeShower.updateTypeShow(_loc_4, _loc_3, _loc_7);
                    }
                    else
                    {
                        this._module.typeShower.updateTypeShow(_loc_4, _loc_3, []);
                    }
                    _loc_6++;
                }
                return;
            }
            if (_loc_5)
            {
                _loc_7 = cache.smallmap.getDataByType(_loc_4, param2);
                this._module.typeShower.updateTypeShow(_loc_4, _loc_3, _loc_7);
            }
            else
            {
                this._module.typeShower.updateTypeShow(_loc_4, _loc_3, []);
            }
            return;
        }// end function

        private function moveStartHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Array;
            this.showMoveTarges();
            if (cache.role.roleInfo.level <= 10 || cache.task.getTaskByCode(GameConst.GuideDefenceCopyTaskCode, true) != null && CopyUtil.isInGuideDefenseCopy)
            {
                if (this._scenePath == null)
                {
                    this._scenePath = new ScenePathShower();
                    this._scenePath.startFrame();
                }
            }
            else if (this._scenePath != null)
            {
                this._scenePath.stopFrame();
                this._scenePath.clear();
                this._scenePath = null;
            }
            return;
        }// end function

        private function showMoveTarges() : void
        {
            if (!this._isCurMap)
            {
                return;
            }
            var _loc_1:* = cache.smallmap.paths;
            if (_loc_1 == null || _loc_1.length == 0)
            {
                return;
            }
            if (this._module == null || this._module.isHide)
            {
                return;
            }
            var _loc_2:* = _loc_1[(_loc_1.length - 1)] as Point;
            var _loc_3:* = AstarAnyDirection.findNearestWalkablePoint(_loc_2.x, _loc_2.y);
            var _loc_4:* = (_loc_3.y + 0.5) * Game.mapInfo.pieceWidth * this._module.mapScale;
            var _loc_5:* = (_loc_3.x + 0.5) * Game.mapInfo.pieceHeight * this._module.mapScale;
            this._module.typeShower.showTargetPoint(true, _loc_4, _loc_5);
            this._module.typeShower.showFlyBoot(this._module.curMapId, true, _loc_4, _loc_5);
            return;
        }// end function

        private function moveEndHandler(param1 = null) : void
        {
            cache.smallmap.clearPaths();
            if (this._module && !this._module.isHide)
            {
                this._module.typeShower.showTargetPoint(false);
                this._module.typeShower.showFlyBoot(this._module.curMapId, false);
                this._module.clearPaths();
            }
            return;
        }// end function

        private function startJumpHandler(param1) : void
        {
            cache.smallmap.fixPathPoint(true);
            this.updateMapPathShows();
            return;
        }// end function

        private function roleWalkGridEndHandler(param1) : void
        {
            cache.smallmap.fixPathPoint();
            this.updateMapPathShows();
            return;
        }// end function

        private function updateMapPathShows() : void
        {
            if (this._scenePath != null)
            {
                this._scenePath.updatePathShow();
            }
            if (this._module && !this._module.isHide)
            {
                if (this._isCurMap)
                {
                    this._module.pathShower.visible = true;
                    this._module.showPathPoints(cache.smallmap.paths);
                    if (this._scenePath != null)
                    {
                        this._scenePath.updatePathShow();
                    }
                    this._module.updateSelfXY();
                }
                else
                {
                    this._module.clearPaths();
                    this._module.pathShower.visible = false;
                }
            }
            return;
        }// end function

        private function stageResizeHandler(event:DataEvent) : void
        {
            return;
        }// end function

        private function smallMapShowHideHandler(event:DataEvent) : void
        {
            if (this._module == null)
            {
                this._module = view as SmallMapModule;
            }
            if (event.data == null || event.data["isShow"] == null)
            {
                if (this._module.isHide)
                {
                    this._module.show();
                }
                else
                {
                    this._module.hide();
                    return;
                }
            }
            else if (event.data != null)
            {
                if (event.data["isShow"])
                {
                    this._module.show();
                }
                else
                {
                    this._module.hide();
                    return;
                }
            }
            this._module.changeToTab(1);
            return;
        }// end function

        private function smallMapClickHandler(event:DataEvent) : void
        {
            var _loc_5:Point = null;
            if (!BuffUtil.isCanRoleWalk())
            {
                MsgManager.showRollTipsMsg(Language.getString(21320));
                return;
            }
            var _loc_2:* = event.data["mapInfo"];
            if (_loc_2 == null)
            {
                _loc_2 = this._module.getShowingMapInfo();
            }
            var _loc_3:* = event.data["x"];
            var _loc_4:* = event.data["y"];
            if (!GameMapUtil.isCanMoveOnClickMap)
            {
                return;
            }
            if (_loc_2 == null || _loc_2.mapId == Game.mapInfo.mapId)
            {
                Scene3DClickProcessor.gotoPoint(new Point(_loc_3, _loc_4), true, 0);
            }
            else
            {
                _loc_5 = new Point();
                _loc_5.x = event.data["x"];
                _loc_5.y = event.data["y"];
                GuideEffect.isShowPath = true;
                if (!AIManager.onAIControl(AIType.GoToOtherMap, Game.mapInfo.mapId, _loc_2.mapId, _loc_5))
                {
                    return;
                }
                this._module.typeShower.showTargetPoint(true, _loc_5.x * this._module.mapScale, _loc_5.y * this._module.mapScale);
                this._module.typeShower.showFlyBoot(this._module.curMapId, true, _loc_5.x * this._module.mapScale, _loc_5.y * this._module.mapScale);
            }
            return;
        }// end function

        private function canUseFlyBoot(param1:int) : Boolean
        {
            if (!GameMapUtil.isCanMoveOnClickMap)
            {
                return false;
            }
            if (!Game.sceneInfo.limitInfo.canPassTo())
            {
                return false;
            }
            var _loc_2:* = this._module.getShowingMapInfo();
            var _loc_3:* = SceneConfig.instance.getSceneInfo(_loc_2.mapId);
            if (_loc_3 == null || !_loc_3.limitInfo.canPassTo())
            {
                return false;
            }
            return true;
        }// end function

        private function smallMapDoubleClickHandler(event:DataEvent) : void
        {
            if (!BuffUtil.isCanRoleWalk())
            {
                MsgManager.showRollTipsMsg(Language.getString(21320));
                return;
            }
            var _loc_2:* = event.data["x"];
            var _loc_3:* = event.data["y"];
            var _loc_4:* = event.data["mapInfo"];
            if (_loc_4 == null)
            {
                _loc_4 = this._module.getShowingMapInfo();
            }
            if (!this.canUseFlyBoot(_loc_4.mapId))
            {
                return;
            }
            var _loc_5:* = _loc_2 / Game.mapInfo.pieceWidth;
            var _loc_6:* = _loc_3 / Game.mapInfo.pieceHeight;
            var _loc_7:* = new SPassTo();
            _loc_7.mapId = _loc_4.mapId;
            var _loc_8:* = new SPoint();
            _loc_7.toPoint = _loc_8;
            if (MapNodeType.isWalk(GameMapUtil.getPointValue(_loc_5, _loc_6, _loc_4.mapData)))
            {
                _loc_7.toPoint.x = _loc_2;
                _loc_7.toPoint.y = _loc_3;
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(21321));
                return;
            }
            if (!FlyBootAI.checkCanFly())
            {
                return;
            }
            this._module.typeShower.showTargetPoint(false);
            this._module.typeShower.showFlyBoot(this._module.curMapId, false);
            this._flyTarget = _loc_7;
            GameController.guide.checkAndBuyFlyBoot(this.startFly);
            return;
        }// end function

        private function startFly() : void
        {
            var _loc_1:SPassPoint = null;
            if (this._flyTarget == null)
            {
                return;
            }
            if (cache.guild.hasGuild && this._flyTarget.mapId == GameConst.guildMapId)
            {
                if (cache.guild.isInGuild && !cache.guild.isInSelfGuild)
                {
                    MsgManager.showRollTipsMsg(Language.getString(21322));
                    return;
                }
                AIManager.cancelAll();
                if (!cache.guild.isInGuild)
                {
                    _loc_1 = new SPassPoint();
                    _loc_1.type = PassAI.EnterGuildType;
                    _loc_1.mapId = cache.guild.selfGuildInfo.baseInfo.guildId;
                    AIManager.addPassToMap(_loc_1);
                }
                AIManager.addFlyBoot(this._flyTarget);
                AIManager.start();
            }
            else
            {
                AIManager.onAIControl(AIType.FlyBoot, this._flyTarget);
            }
            return;
        }// end function

        private function smallMapFlybootReqHandler(event:DataEvent) : void
        {
            if (!BuffUtil.isCanRoleWalk())
            {
                MsgManager.showRollTipsMsg(Language.getString(21320));
                return;
            }
            var _loc_2:* = this._module.getShowingMapInfo();
            if (!this.canUseFlyBoot(_loc_2.mapId))
            {
                return;
            }
            var _loc_3:* = event.data as SPoint;
            var _loc_4:* = Game.mapInfo.mapId;
            _loc_3.x = _loc_3.x / this._module.mapScale;
            _loc_3.y = _loc_3.y / this._module.mapScale;
            this._module.typeShower.showTargetPoint(false);
            this._module.typeShower.showFlyBoot(this._module.curMapId, false);
            var _loc_5:* = new SPassTo();
            _loc_5.mapId = _loc_2.mapId;
            _loc_5.toPoint = _loc_3;
            event.data = _loc_5;
            this.flyReqHandler(event);
            return;
        }// end function

        private function showCurPointHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["x"];
            var _loc_3:* = event.data["y"];
            if (this._module != null)
            {
                this._module.rightDown.updateMouseXY(_loc_2, _loc_3);
            }
            return;
        }// end function

        private function showTypeChangeHandler(event:DataEvent) : void
        {
            var _loc_4:Object = null;
            var _loc_2:* = event.data["type"];
            var _loc_3:* = event.data["value"];
            ClientSetting.local.setIsDone(_loc_3, _loc_2);
            var _loc_5:* = cache.smallmap.getRightTopShowTypes();
            var _loc_6:int = 0;
            while (_loc_6 < _loc_5.length)
            {
                
                if (_loc_5[_loc_6]["type"] == _loc_2)
                {
                    _loc_4 = _loc_5[_loc_6];
                    break;
                }
                _loc_6++;
            }
            if (_loc_4 != null)
            {
                this.updateMapPointTypeShow(_loc_4, Game.mapInfo.mapId);
            }
            return;
        }// end function

        public function get curMapId() : int
        {
            return this._module ? (this._module.curMapId) : (0);
        }// end function

    }
}
